<template>
  <div class="app-container">
    <div class="filter-container default-box">
      <span>日期：</span>
      <el-date-picker
        v-model="listQuery.date"
        type="date"
        placeholder="请选择日期"
        format="yyyy 年 MM 月 dd 日"
        value-format="yyyy-MM-dd"
      />
      <span style="padding-left: 50px">类型：</span>
      <el-select v-model="listQuery.type" filterable placeholder="请选择">
        <el-option v-for="item in statusoptions" :key="item.value" :label="item.label" :value="item.value" />
      </el-select>
      <el-button class="filter-item" type="primary" icon="el-icon-search" style="margin-left:50px" round @click="handleFilter">
        查询
      </el-button>
      <el-button class="filter-item" icon="el-icon-refresh-right" round @click="handlReset">
        重置
      </el-button>
    </div>
    <div class="default-box">
      <el-table
        :key="tableKey"
        v-loading="listLoading"
        :data="list"
        fit
        highlight-current-row
        style="width: 100%;"
      >
        <el-table-column label="用户">
          <template>
            <span>123456</span>
          </template>
        </el-table-column>
        <el-table-column label="类型">
          <template>
            <span>广告包交易</span>
          </template>
        </el-table-column>
        <el-table-column label="积分">
          <template>
            <span>
              1000.0000
            </span>
          </template>
        </el-table-column>
        <el-table-column label="手续费比例">
          <template>
            <span>0.00</span>
          </template>
        </el-table-column>
        <el-table-column label="手续费">
          <template>
            <span>1000.0000</span>
          </template>
        </el-table-column>
        <el-table-column label="时间">
          <template>
            <span>
              2023-03-15 17:25:28
            </span>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
    </div>
  </div>
</template>

<script>
import { fetchList } from '@/api/article'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
export default {
  name: 'Recycle',
  components: { Pagination },
  data() {
    return {
      tableKey: 0,
      list: null,
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 10,
        date: '',
        type: ''
      },
      statusoptions: [{ // 状态选择项组
        value: '',
        label: '不限'
      }, {
        value: '广告包交易',
        label: '广告包交易'
      }]
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      fetchList(this.listQuery).then(response => {
        this.list = response.data.items
        this.total = response.data.total
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    },
    // 重置
    handlReset() {
      this.listQuery.account = ''
    },
    // 搜索
    handleFilter() {
      this.getList()
    }
  }
}
</script>
<style scoped>
  [class^=el-icon-], [class*=" el-icon-"]{
    font-size: 16px;
  }
  .small-padding i{
    margin-right: 12px;
  }
  .small-padding i:last-child{
    margin-right: 0px;
  }
</style>
